<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
        constructor
        ① 父类中如果显式定义，带参数的 constructor，子类必须要重写，并调用父类 constructor
        ② 子类 constructor 的参数应该和父类保持一致
      */
      class Animal {
        username = "jack";
        constructor(a, b, c) {
          console.log(this.username); //jack
          console.log(a + b + c);
        }
      }
      class Cat extends Animal {
        username = "lili";
        constructor(...agrs) {
          super(...agrs); // super.constructor()
        }
      }
      const c = new Cat(10, 20, 30); // new constructor(10,20,30)
    </script>
  </body>
</html>
